import 'package:earclean/app/config/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

final box = GetStorage();

final channel = MethodChannel("methodChannel");

//复制
Future copyText(text) {
  return Clipboard.setData(ClipboardData(text: text));
}

Future MshowDialog(String title,
    {String confirmtitle = "确定", String cancelTitle = '取消'}) {
  return Get.dialog(
    AlertDialog(
      shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(10))),
      clipBehavior: Clip.none,
      contentPadding: EdgeInsets.zero,
      backgroundColor: Colors.transparent,
      elevation: 0,
      content: Container(
        height: 142,
        decoration: const BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(10))),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              // height: 105,
              padding: const EdgeInsets.symmetric(vertical: 30, horizontal: 15),
              alignment: Alignment.center,
              // child: Html(data: title,style: {}),
              child: Text(
                title,
                textAlign: TextAlign.center,
                style: TextStyle(
                    fontSize: 16.sp,
                    color: ColorConfig.text_label,
                    fontWeight: FontWeight.w500),
              ),
            ),
            // Container(
            //   width: 1.sw,
            //   height: .5,
            //   color: Color(0xFFDDDDDD),
            // ),
            Container(
                height: 45,
                margin: EdgeInsets.symmetric(horizontal: 30),
                child: Row(
                  children: [
                    // Expanded(
                    //   child: InkWell(
                    //     onTap: () {
                    //       Get.back(result: 0);
                    //     },
                    //     child: Center(
                    //       child: Text(cancelTitle,
                    //           style: TextStyle(
                    //               color: const Color(0xFF999999),
                    //               fontFamily: 'mononoki',
                    //               fontSize: 16.sp)),
                    //     ),
                    //   ),
                    // ),
                    Expanded(
                      child: Container(
                        child: ElevatedButton(
                          style: ElevatedButton.styleFrom(
                              primary: ColorConfig.white,
                              shape: RoundedRectangleBorder(
                                side: BorderSide(
                                    color: ColorConfig.app_main, width: 1),
                                borderRadius: BorderRadius.circular(10),
                              )),
                          onPressed: () {
                            Get.back(result: 0);
                          },
                          child: Text(cancelTitle,
                              style: TextStyle(
                                  fontSize: 15,
                                  color: ColorConfig.subtitle_text,
                                  fontWeight: FontWeight.w400)),
                        ),
                      ),
                    ),
                    Container(
                      width: 35,
                    ),
                    Expanded(
                        child: Container(
                      child: ElevatedButton(
                        style: ElevatedButton.styleFrom(
                            primary: ColorConfig.app_main,
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(10),
                            )),
                        onPressed: () {
                          Get.back(result: 1);
                        },
                        child: Text(confirmtitle,
                            style: TextStyle(
                                fontSize: 15,
                                color: ColorConfig.white,
                                fontWeight: FontWeight.w400)),
                      ),
                    )),
                    // Expanded(
                    //     child: InkWell(
                    //   onTap: () {
                    //     Get.back(result: 1);
                    //   },
                    //   child: Center(
                    //     child: Text(confirmtitle,
                    //         style: TextStyle(
                    //             color: ColorConfig.app_main,
                    //             fontFamily: 'mononoki',
                    //             fontSize: 16.sp)),
                    //   ),
                    // )),
                  ],
                )),
          ],
        ),
      ),
    ),
    barrierColor: Colors.black.withAlpha(20),
  );
}
